

clear all
insheet using "$data/raw_data/survey1.csv", names clear
drop in 1/2

keep if rid!=""
duplicates drop rid, force

drop in 1/2

destring *, replace

keep if finish==1

********************************************************************************
********************************************************************************
********* Mortality treatment indicators ***************************************
********************************************************************************
********************************************************************************

gen highmort = highmortality==1
gen lowhmort = highmortality==0
label var highmortality "High releative mortality treatment"
label var highmort "High releative mortality treatment"
label var lowhmort "Low releative mortality treatment"
label var contagiontreatment "Contagiousness treatment"
***********************
**** Add case data ****
***********************


gen casesmarch5 = 0
replace casesmarch5 = 1 if state==3
replace casesmarch5 = 51 if state==5
replace casesmarch5 = 3 if state==10
replace casesmarch5 = 2 if state==11
replace casesmarch5 = 5 if state==14
replace casesmarch5 = 2 if state==22
replace casesmarch5 = 1 if state==29
replace casesmarch5 = 2 if state==30
replace casesmarch5 = 2 if state==31
replace casesmarch5 = 23 if state==33
replace casesmarch5 = 1 if state==34
replace casesmarch5 = 3 if state==38
replace casesmarch5 = 2 if state==41
replace casesmarch5 = 1 if state==44
replace casesmarch5 = 3 if state==45
replace casesmarch5 = 70 if state==49

gen anycase_march5 = casesmarch5>0

label var anycase_march5 "Any Coronavirus case in state"
label var casesmarch5 "# of Coronavirus cases in state"

********************************************************************************
********************************************************************************
*clean demographics.
********************************************************************************
********************************************************************************

recode male (2=0)(3=0)

gen age_18_24=age==1 if age!=.
gen age_25_34=age==2 if age!=.
gen age_35_44=age==3 if age!=.
gen age_45_54=age==4 if age!=.
gen age_55_64=age==5 if age!=.
gen age_65=age==6 if age!=.

label var age_18_24 "Aged 18 to 24"
label var age_25_34 "Aged 25 to 34"
label var age_35_44 "Aged 35 to 44"
label var age_45_54 "Aged 45 to 54"
label var age_55_64 "Aged 55 to 64"
label var age_65 "Aged 65 above"


gen empl_ft=emply==1 if emply!=.
gen empl_pt=emply==2 if emply!=.


gen inc_15=hhincome==1 if hhincome!=.&hhincome!=9
gen inc_15_25=hhincome==2 if hhincome!=.&hhincome!=9
gen inc_25_50=hhincome==3 if hhincome!=.&hhincome!=9
gen inc_50_75=hhincome==4 if hhincome!=.&hhincome!=9
gen inc_75_100=hhincome==5 if hhincome!=.&hhincome!=9
gen inc_100_150=hhincome==6 if hhincome!=.&hhincome!=9
gen inc_150_200=hhincome==7 if hhincome!=.&hhincome!=9
gen inc_200=hhincome==8 if hhincome!=.&hhincome!=9

gen inc=.
replace inc=10000 if hhincome==1
replace inc=20000 if hhincome==2
replace inc=37500 if hhincome==3
replace inc=62500 if hhincome==4
replace inc=87500 if hhincome==5
replace inc=125000 if hhincome==6
replace inc=175000 if hhincome==7
replace inc=250000 if hhincome==8


gen log_inc=log(inc) 
gen log_inc_sq=(log_inc)^2

label var log_inc "Log income"
label var log_inc_sq "Log income squared"

gen unemp = emply==4 if emply!=.
label var unemp "Unemployed"
gen student = emply==9 if emply!=.
label var student "Student"
gen working = inlist(emply,1,2,3) if emply!=.
label var working "Working full or part time"

gen below_highschool=educ==1 if educ!=.
gen highschool=educ==2 if educ!=.
label var highschool "Highest degree: highschool"
gen college=educ>2 if educ!=.
label var college "Some post secondary education"

gen democrat = pol==2 if pol!=.
gen republican = pol==1 if pol!=.
gen independent = pol==3 if pol!=.
gen pol_other = pol==4 if pol!=.


gen college_degree =educ>=5
label var college_degree "Has college degree"


***** Impact questions checks **********
ren manip_* impact_*
label var  impact_1 "The World will be severely affected by the coronavirus."
label var impact_2 "The US will be severely affected by the coronavirus."

forval l=1/4 {
ren impact_update_`l' impact_`l'_update 
}
recode impact_1  impact_2    (18=1)(19=2)(20=3)(21=4)(22=5) // High is pessimistic
label define impact 1 "Strongly  disagree" 2"Disagree" 3 "Neither agree nor disagree" 4 "Agree" 5 "Strongly agree" 
label val impact_1  impact
label val impact_2  impact


ren worry_econ_update worry_corona_econ_update 
ren worry_econpersonal worry_perecon

recode worry_corona_econ worry_perecon worry_corona_econ_update worry_perecon_update (4=1)(3=2)(2=3)(1=4) // High is worried

label define worry 1 "Not at all worried" 2  "Not worried"  3 "Worried" 4 "Very worried"
label val worry_corona_econ worry
label val worry_perecon worry

label var worry_corona_econ "Are you worried about the effects of the coronavirus on the US economy?"
label var worry_perecon "Are you worried about the effects of the coronavirus on your household's economic situation?"

label var worry_corona_econ_update "After contagion treatment: Are you worried about the effects of the coronavirus on the US economy?"
label var worry_perecon_update "After contagion treatment: Are you worried about the effects of the coronavirus on your household's economic situation?"


foreach x in impact_1  impact_2  worry_corona worry_corona_econ worry_perecon impact_1_update impact_2_update   worry_corona_econ_update worry_perecon_update  {
label val `x'  manip 
egen z_`x' = std(`x')
label var z_`x' "Standardized values of (`x')." 
}


**********

ren perceived_motailty perceived_mortality 

foreach x in perceived_mortality  perceived_contagion  {
sum `x' ,d
gen `x'_w = `x'
replace `x'_w = r(p95) if `x'>r(p95) & `x'!=.
label var `x'_w "`x' winsorized at 95th percentile."

gen `x'_fig = `x'
replace `x'_fig = 50 if `x'>50 & `x'!=.
label var `x'_fig "`x' topcoded at 50."
}

* Labeling *



label var male "Male"
label var age "Age (categorical)"
label var  incomedem "Income"
label var highschool "Highschool education"
label var college "College eductation"
label var working "Currently working"
label var unemp "Unemployed"
label var student "Student"
label var democrat "Democrat"
label var republican "Republican"

label var perceived_mortality "Predicted  mortality rate"
label var perceived_contagion "Infectiousness (R_0)"


keep  male age age_25_34 age_35_44 age_45_54 age_55_64 age_65 inc log_inc state  highmort lowhmort  contagiontreatment trust_science highmortality ///
highschool college* unemp working student democrat republican *worry_corona_econ* *worry_perecon* impact_1 impact_2 z_impact_1 z_impact_2 ///
anycase_march5 perceived_mortality* perceived_contagion* log_inc_sq log_inc 


save "$data/survey1_clean.dta", replace





